package com.lcm.algorithm.datatest.sort;

import java.util.Arrays;

/**
 * @description:
 * @author: lcm
 * @create: 2020-04-08 16:40
 **/

public class InsertionSort {

    public static void main(String[] args) {
        int[] n = new int[]{6, 5, 2, 7, 3, 9, 8, 4, 10, 1};
        sort(n);
        System.out.println(Arrays.toString(n));
    }

    public static void sort(int[] nums){
        for(int i=1;i<nums.length;i++){
            for(int j=i;j>0&&nums[j]<nums[j-1];j--){
                int temp=nums[j-1];
                nums[j-1]=nums[j];
                nums[j]=temp;
            }
        }
    }
}
